package ferp.android.ads.interstitial;

import android.content.Context;
import ferp.android.managers.BonusManager;

/**
 * User: olegs
 * Date: 14/07/2014 10:49
 */
public class InterstitialAdManager
{
  public interface Provider
  {
    // load an interstitial ad
    void load(Context context);
    // show an interstitial ad
    void show();
  }

  public static void initialize(Context context)
  {
    InterstitialAdManager.context = context.getApplicationContext();
  }

  public static void setEnabled(boolean enabled) {InterstitialAdManager.enabled = enabled;}

  public static void load()
  {
    if (enabled && !BonusManager.instance(context).isActive())
      adMob.load(context);
  }

  public static void show()
  {
    if (enabled && !BonusManager.instance(context).isActive())
      adMob.show();
  }

  public static void stop()
  {
    // for symmetry purpose (like in MediationAdManager)
  }

  // AdMob provider
  private static final AdmobInterstitialAdProvider adMob = new AdmobInterstitialAdProvider();
  // application context
  private static Context context;
  // enabled flag
  private static boolean enabled;
}
